//
//  XQHomeBigCardView.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/19.
//

#import "XQHomeBigCardView.h"
#import "XQHomeBigApplyingView.h"
#import "XQHomeBigInstitutionsView.h"
#import "XQHomeBigAboutView.h"
#import "XQHomeBigGuideView.h"

@interface XQHomeBigCardView()
@property (nonatomic,strong) XQHomeBigApplyingView *applyingView;
@property (nonatomic,strong) XQHomeBigInstitutionsView *institutionsView;
@property (nonatomic,strong) XQHomeBigAboutView *aboutView;
@property (nonatomic,strong) XQHomeBigGuideView *guideView;
@end

@implementation XQHomeBigCardView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self makeUI];
        [self makeConstraints];
    }
    return self;
}

- (void)makeUI {
    [self addSubview:self.applyingView];
    [self addSubview:self.institutionsView];
    [self addSubview:self.aboutView];
    [self addSubview:self.guideView];
}

- (void)makeConstraints {
    [self.applyingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.right.equalTo(@0);
    }];
    [self.institutionsView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.applyingView.mas_bottom).offset(16);
        make.left.right.equalTo(@0);
    }];
    [self.aboutView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.institutionsView.mas_bottom).offset(16);
        make.left.right.equalTo(@0);
    }];
    [self.guideView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.aboutView.mas_bottom).offset(16);
        make.left.right.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
}


#pragma mark - setter

- (void)setDataSource:(NSArray *)dataSource {
    [self.applyingView setDataSource:dataSource];
}

#pragma mark - lazy

- (XQHomeBigApplyingView *)applyingView {
    if (!_applyingView) {
        _applyingView = [[XQHomeBigApplyingView alloc] init];
        @weakify(self);
        _applyingView.didSelectHandle = ^(NSString * _Nonnull url) {
            @strongify(self);
            if (self.didSelectHandle) {
                self.didSelectHandle(url);
            }
        };
    }
    return  _applyingView;
}

- (XQHomeBigInstitutionsView *)institutionsView {
    if (!_institutionsView) {
        _institutionsView = [[XQHomeBigInstitutionsView alloc] init];
    }
    return _institutionsView;
}

- (XQHomeBigAboutView *)aboutView {
    if (!_aboutView) {
        _aboutView = [[XQHomeBigAboutView alloc] init];
        @weakify(self)
        _aboutView.moreHandle = ^{
            @strongify(self);
            if (self.moreHandle) {
                self.moreHandle();
            }
        };
    }
    return _aboutView;
}

- (XQHomeBigGuideView *)guideView {
    if (!_guideView) {
        _guideView = [[XQHomeBigGuideView alloc] init];
    }
    return _guideView;
}

@end
